package com.fengcheng.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class hdfsUser implements Writable {

    private String username;
    private Integer age;
    private String address;

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        // 把对象序列化
        dataOutput.writeChars(username);
        dataOutput.writeInt(age);
        dataOutput.writeChars(address);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        // 把序列化的对象读取到内存中
        username = dataInput.readUTF();
        age = dataInput.readInt();
        address = dataInput.readUTF();
    }



}
